function loadImage(size = 5, startIndex, endIndex) {
    const promise = Promise.resolve();

    const load = index => {};
    const process = [];
    for (let i = startIndex; i <= endIndex; i++) {
        process.push(
            new Promise((resolve, reject) => {
                const url = `http://image.zhangxinxu.com/image/study/s/s256/mm${i}.jpg`;
                const img = new Image();
                img.src = url;
                img.onload = () => {
                    resolve(img);
                };
            })
        );
    }
    return Promise.all(process);
}

const imgList = (() => {
    const imgList = [];
    for (let i = 1; i <= 20; i++) {
        const index = i - 1;
        if (index % 5 === 0 || index === 0) {
            imgList.push({ start: i, end: index + 5 });
        }
    }
    return imgList;
})();
function run() {
    if (imgList.length) {
        const imgData = imgList.shift();
        loadImage(5, imgData.start, imgData.end).then(() => {
            run();
        });
    }
}
run();
